Split native and Panama OSQ vector scorer implementations#144667
Open
ChrisHegarty wants to merge 8 commits intoelastic:mainfrom
Open
Split native and Panama OSQ vector scorer implementations#144667ChrisHegarty wants to merge 8 commits intoelastic:mainfrom
ChrisHegarty wants to merge 8 commits intoelastic:mainfrom
Conversation
Collaborator
|
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
Contributor
Author
|
Buildkite benchmark this with so-vector please |
Contributor
Author
|
Buildkite benchmark this with dense-vector please |
Contributor
Author
|
Buildkite benchmark this with so-vector please |
Contributor
Author
|
Buildkite benchmark this with dense-vector please |
Collaborator
💔 Build Failed
Failed CI StepsThis build attempts two dense-vector benchmarks to evaluate performance impact of this PR. To estimate benchmark completion time inspect previous nightly runs here. History
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The OSQ vector scorer methods have grown cluttered with nested
if/elsebranches testingNATIVE_SUPPORTED,SUPPORTS_HEAP_SEGMENTS, andVECTOR_BITSIZE, all static final constants. I am concerned about maintenance and JIT inlining, since the large bytecode size of these methods could prevent the JVM from inlining them on the hot path. So I split the native (FFI) and Panama (Vector API) implementations into separate class hierarchies.A
NativeMemorySegmentScorerabstract base provides template methods for quantize, bulk scoring, and corrections. Three small final subclasses (one per quant type) supply only the native dot-product function pointers and bit scales. The existingMS*scorers are now Panama-only, with all native branches removed. The right implementation is selected once at class-load time via a static factory map, keyed on query/index bit combination.I also moved the
dataLength >= 16SIMD minimum check from every method call to construction time, so the native hot-path methods have no unnecessary runtime guards. A nice consequence of this is that the filtered KNN path (scoreBulkOffsets) now uses fully native scoring, both quantize and bulk corrections end-to-end. Previously it used native quantize but fell back to scalar corrections. I also replacedreadInt()loops with bulkreadInts()in the baseESNextOSQVectorsScorer.